{% extends "base.html" %}

{% block title %}编辑数据字典 - 网站管理后台{% endblock %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h1 class="h2">编辑数据字典</h1>
</div>

<div class="row">
    <div class="col-md-6">
        <form method="POST">
            <div class="mb-3">
                <label for="code" class="form-label">编码</label>
                <input type="text" class="form-control" id="code" name="code" value="{{ dictionary[1] }}" readonly>
            </div>
            <div class="mb-3">
                <label for="name" class="form-label">名称</label>
                <input type="text" class="form-control" id="name" name="name" value="{{ dictionary[2] }}" required>
            </div>
            <div class="mb-3">
                <label for="category" class="form-label">分类</label>
                <input type="text" class="form-control" id="category" name="category" value="{{ dictionary[3] if dictionary[3] else '' }}">
            </div>
            <div class="mb-3">
                <label for="description" class="form-label">描述</label>
                <textarea class="form-control" id="description" name="description" rows="3">{{ dictionary[4] if dictionary[4] else '' }}</textarea>
            </div>
            <div class="mb-3">
                <label for="sort_order" class="form-label">排序</label>
                <input type="number" class="form-control" id="sort_order" name="sort_order" value="{{ dictionary[5] }}">
            </div>
            <div class="mb-3 form-check">
                <input type="checkbox" class="form-check-input" id="status" name="status" {% if dictionary[6] == 1 %}checked{% endif %}>
                <label class="form-check-label" for="status">启用</label>
            </div>
            <button type="submit" class="btn btn-primary">更新字典</button>
            <a href="{{ url_for('web.data_dictionaries') }}" class="btn btn-secondary">取消</a>
        </form>
    </div>
</div>
{% endblock %}